package gdt.entity;

import java.io.Serializable;
import java.lang.String;
import java.util.Date;
import javax.persistence.*;

import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;

/**
 * Entity that represents an announcement
 */
@NamedQueries({
		@NamedQuery(name="findProjectAnnouncementsByUser",query="select a from ProjectAnnouncement a join a.project p join p.assignedMembers m where m = :member"),
		@NamedQuery(name="findGroupAnnouncementsByUser",query="select a from GroupAnnouncement a join a.group g join g.members m where m = :member")
})
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public abstract class Announcement extends AbstractSecureEntity implements Serializable, Comparable<Announcement> {

	private static final long serialVersionUID = 1L;
	   
	@NotEmpty
	private String title;
	
	private String description;
	
	@NotNull
	private Date date;
	
	
	public Announcement() {
		super();
	}   
	
	// ********************** Accessor Methods ********************** //

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}   
	
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}   
	
	public Date getDate() {
		return this.date;
		
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public int compareTo(Announcement announcement) {
		return date.compareTo(announcement.getDate());
	}
   
}
